package com.spice.common.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.List;

public class ShellUtil {

    public static boolean executeCommand(String... arguments) {
        try {
            Process process = Runtime.getRuntime().exec(arguments);

            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            process.waitFor();
            return true;
        } catch (Exception e) {
            return false;
        }
    }

    public static void main(String[] args) {
        System.out.println(ShellUtil.executeCommand("./resources/shell/backup.sh",
                "spice_info_platform", "user", "./test1.sql"));
    }
}
